package com.xc.hotelmgr.datahandlermt.controller;

import com.xc.hotelmgr.datahandlermt.pojo.mq.SendAllList;
import com.xc.hotelmgr.datahandlermt.pojo.mq.SendRs;
import com.xc.hotelmgr.datahandlermt.pojo.mq.UpDownList;
import com.xc.hotelmgr.datahandlermt.result.MtResult;
import com.xc.hotelmgr.datahandlermt.service.mt.HotelToMQService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("hotel")
@RequiredArgsConstructor
public class HotelToMqController {


    private final HotelToMQService hotelToMQService;

    /**
     * 店铺下的酒店上下架(前端调用）
     * @param store_id
     * @param status
     * @return
     */
    @RequestMapping(value = "/state/{store_id}/{status}", method = RequestMethod.GET)
    public MtResult UpDownStore(@PathVariable("store_id") int store_id, @PathVariable("status") int status) {
        hotelToMQService.upDown(store_id, status);
        return new MtResult(0, "成功");
    }

    /**
     * 店铺酒店批量上下架（前端调用）
     * @param upDownList
     * @return
     */
    @RequestMapping(value = "/state", method = RequestMethod.POST)
    public MtResult UpDownHotelList(@RequestBody UpDownList upDownList) {
        hotelToMQService.upDownList(upDownList);
        return new MtResult(0, "成功");
    }

    /**
     * 店铺初始化，店铺下的酒店全量推送（前端调用）
     * @param store_id
     * @return
     */
    @RequestMapping(value = "/send_all/{store_id}", method = RequestMethod.GET)
    public MtResult hotelAllSend(@PathVariable("store_id") int store_id) {
        hotelToMQService.sendAll(store_id);
        return new MtResult(0, "成功");
    }

    /**
     * 推送店铺下的RP（前端调用）
     * @param sendRs
     * @return
     */
    @RequestMapping(value = "/send_rs", method = RequestMethod.POST)
    public MtResult hotelRsSend(@RequestBody SendRs sendRs) {
        hotelToMQService.sendRs(sendRs);
        return new MtResult(0, "成功");
    }

    /**
     * 推送指定店铺下的酒店，放入 sendAll_#{appkey}队列中（前端调用）
     * @param sendAllList
     * @return
     */
    @RequestMapping(value = "/send_all", method = RequestMethod.POST)
    public MtResult hotelAllSendList(@RequestBody SendAllList sendAllList) {
        hotelToMQService.sendAllList(sendAllList);
        return new MtResult(0, "成功");
    }
}
